﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace TAM_SPORT
{
    public partial class Capture : Form
    {
        public Capture()
        {
            InitializeComponent();
            try
            {
                videoCap1.StopPreviewWindow();
                videoCap1.PreviewVideo();
                videoCap1.StopPreviewWindow();
                videoCap1.PreviewVideo();
            }
            catch
            {
                videoCap1.Dispose();
                videoCap1 = new LN_VideoCapture.VideoCap();
                videoCap1.PreviewVideo();
            }
        }
        private Image image;

        private string filename;

        public string Filename
        {
            get { return filename; }
            set { filename = value; }
        }

        public Image Image
        {
            get { return image; }
            set { image = value; }
        }
        private void btnCapture_Click(object sender, EventArgs e)
        {
            if (ShareMethod.createFolder(@"C:\HINHANHCLS"))
            {
                if (!ShareMethod.emptyFolder(new DirectoryInfo(@"C:\HINHANHCLS")))
                {
                    MessageBox.Show(@"Vui lòng đóng thư mục C:\HINHANHCLS trước khi chụp hình hoặc siêu âm");
                    return;
                }
            }
            string path = @"C:\HINHANHCLS\" + System.DateTime.Now.ToString("yyMMddhhmmss") + ".jpg";
            this.filename = path;
            videoCap1.m_ImageFileName = path;
            videoCap1.CaptureImage();
            videoCap1.StopPreviewWindow();
            videoCap1.Dispose();
            this.Close();
        }

        private void Capture_Load(object sender, EventArgs e)
        {

        }

        private void btnRestart_Click(object sender, EventArgs e)
        {
            videoCap1.StopPreviewWindow();
            videoCap1.PreviewVideo();
        }
    }
}
